package com.tanhua.server.controller;

import com.tanhua.server.service.CommentsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("/messages")
public class MessagesController {

    @Autowired
    private CommentsService commentsService;

    @GetMapping(value = "/likes",name = "查询对当前登录人圈子的点赞人")
    public ResponseEntity likes(@RequestParam(defaultValue = "1") Integer page,
                                @RequestParam(defaultValue = "10")Integer pagesize){

        return commentsService.queryCommentsPeople(page,pagesize,1);
    }

    @GetMapping(value = "/comments",name = "查询对当前登录人圈子的评论人")
    public ResponseEntity comments(@RequestParam(defaultValue = "1") Integer page,
                                @RequestParam(defaultValue = "10")Integer pagesize){

        return commentsService.queryCommentsPeople(page,pagesize,2);
    }

    @GetMapping(value = "/loves",name = "查询对当前登录人圈子的喜欢人")
    public ResponseEntity loves(@RequestParam(defaultValue = "1") Integer page,
                                @RequestParam(defaultValue = "10")Integer pagesize){

        return commentsService.queryCommentsPeople(page,pagesize,3);
    }

    @PostMapping(value = "/contacts",name = "聊一下成为好友")
    public ResponseEntity contacts(@RequestBody Map map){

      Long userId = Long.parseLong( map.get("userId").toString());

      return commentsService.contacts(userId);
    }

    @GetMapping(value = "/contacts",name = "分页查询好友")
    public ResponseEntity queryContacts(@RequestParam(defaultValue = "1") Integer page,
                                        @RequestParam(defaultValue = "10")Integer pagesize){

      return commentsService.queryContacts(page,pagesize);
    }


}
